<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Tiendalia - Panel de usuario</title>
    </h:head>
    <h:body>
        <ui:composition template="template.xhtml">
            <ui:define name="content">
                <h:form id="advSearchForm">
                    <p:dataTable id="searchTable" styleClass="adminTable" var="product" value="#{advSearchBean.productsModel}" selectionMode="single" selection="#{advSearchBean.selectedProduct}">
                        <p:ajax event="rowSelect" update=":advSearchForm:searchTable" />
                        <f:facet name="header">
                            <h:outputText styleClass="headerTitle" value="Búsqueda Avanzada" />
                        </f:facet>
                        <p:column headerText="Nombre" sortBy="#{product.name}" filterBy="#{product.name}">
                            <p:commandLink action="#{advSearchBean.goToProduct(product.id)}" value="#{product.name}" />
                        </p:column>
                        <p:column headerText="Precio" sortBy="#{product.price}" filterBy="#{product.price}">
                            <h:outputText value="#{product.price}">
                                <f:convertNumber currencySymbol="€" type="currency" />
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Categoría" filterBy="#{product.category}" filterOptions="#{advSearchBean.categories}">
                            <h:outputText value="#{product.category}" />
                        </p:column>
                        <p:column headerText="Descripción" filterMatchMode="contains" filterBy="#{product.description}" >
                            <h:outputText value="#{product.description}" />
                        </p:column>
                    </p:dataTable>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>